<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"><title>Ajax第四天 | XC's Blog</title><meta name="keywords" content="Ajax笔记"><meta name="author" content="XC's Blog"><meta name="copyright" content="XC's Blog"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="Day04_AJAX进阶知识点自测 看如下标签回答如下问题？ 12345&lt;select&gt;    &lt;option value&#x3D;&quot;北京&quot;&gt;北京市&lt;&#x2F;option&gt;    &lt;option value&#x3D;&quot;南京&quot;&gt;南京市&lt;&#x2F;option&gt;    &lt;option value&#x3D;&quot;天津&quot;&amp;"><meta property="og:type" content="article"><meta property="og:title" content="Ajax第四天"><meta property="og:url" content="https://webxc.eu.org/post/or01/index.html"><meta property="og:site_name" content="XC&#39;s Blog"><meta property="og:description" content="Day04_AJAX进阶知识点自测 看如下标签回答如下问题？ 12345&lt;select&gt;    &lt;option value&#x3D;&quot;北京&quot;&gt;北京市&lt;&#x2F;option&gt;    &lt;option value&#x3D;&quot;南京&quot;&gt;南京市&lt;&#x2F;option&gt;    &lt;option value&#x3D;&quot;天津&quot;&amp;"><meta property="og:locale" content="zh_CN"><meta property="og:image" content="https://cdn1.tianli0.top/gh/web-xc/iMG/postss/ajax.webp"><meta property="article:published_time" content="2023-06-08T10:00:00.000Z"><meta property="article:modified_time" content="2023-08-30T18:00:49.013Z"><meta property="article:author" content="XC&#39;s Blog"><meta property="article:tag" content="Ajax笔记"><meta name="twitter:card" content="summary"><meta name="twitter:image" content="https://cdn1.tianli0.top/gh/web-xc/iMG/postss/ajax.webp"><link rel="shortcut icon" href="https://npm.elemecdn.com/webxc@1.0.0/logo/logo.jpg"><link rel="canonical" href="https://webxc.eu.org/post/or01/"><link rel="preconnect" href="//cdn.jsdelivr.net"><link rel="preconnect" href="//busuanzi.ibruce.info"><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://npm.elemecdn.com/@fortawesome/fontawesome-free@6.2.0/css/all.min.css" media="print" onload='this.media="all"'><link rel="stylesheet" href="https://npm.elemecdn.com/node-snackbar/dist/snackbar.min.css" media="print" onload='this.media="all"'><link rel="stylesheet" href="https://npm.elemecdn.com/@fancyapps/ui/dist/fancybox.css" media="print" onload='this.media="all"'><script>const GLOBAL_CONFIG={root:"/",algolia:void 0,localSearch:{path:"/search.xml",preload:!1,languages:{hits_empty:"找不到您查询的内容：${query}"}},translate:void 0,noticeOutdate:void 0,highlight:{plugin:"highlighjs",highlightCopy:!0,highlightLang:!0,highlightHeightLimit:!1},copy:{success:"吾辈宣布,你的剪切板已被占领",error:"呀~复制失败,请在尝试下",noSupport:"对不起,你的浏览器不支持"},relativeDate:{homepage:!1,post:!1},runtime:"",date_suffix:{just:"刚刚",min:"分钟前",hour:"小时前",day:"天前",month:"个月前"},copyright:{limitCount:60,languages:{author:"作者: XC's Blog",link:"链接: ",source:"来源: XC's Blog",info:"著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。"}},lightbox:"fancybox",Snackbar:{chs_to_cht:"您已切换为繁体",cht_to_chs:"您已切换为简体",day_to_night:"您已切换为深色主题",night_to_day:"您已切换为浅色主题",bgLight:"#3b70fc",bgDark:"#121212",position:"bottom-center"},source:{justifiedGallery:{js:"https://npm.elemecdn.com/flickr-justified-gallery/dist/fjGallery.min.js",css:"https://npm.elemecdn.com/flickr-justified-gallery/dist/fjGallery.css"}},isPhotoFigcaption:!1,islazyload:!0,isAnchor:!0}</script><script id="config-diff">var GLOBAL_CONFIG_SITE={title:"Ajax第四天",isPost:!0,isHome:!1,isHighlightShrink:!1,isToc:!0,postUpdate:"2023-08-30 18:00:49"}</script><noscript><style>#nav{opacity:1}.justified-gallery img{opacity:1}#post-meta time,#recent-posts time{display:inline!important}</style></noscript><script>(e=>{e.saveToLocal={set:function(e,t,o){if(0===o)return;const n=864e5*o,a={value:t,expiry:(new Date).getTime()+n};localStorage.setItem(e,JSON.stringify(a))},get:function(e){const t=localStorage.getItem(e);if(!t)return;const o=JSON.parse(t);if(!((new Date).getTime()>o.expiry))return o.value;localStorage.removeItem(e)}},e.getScript=e=>new Promise(((t,o)=>{const n=document.createElement("script");n.src=e,n.async=!0,n.onerror=o,n.onload=n.onreadystatechange=function(){const e=this.readyState;e&&"loaded"!==e&&"complete"!==e||(n.onload=n.onreadystatechange=null,t())},document.head.appendChild(n)})),e.activateDarkMode=function(){document.documentElement.setAttribute("data-theme","dark"),null!==document.querySelector('meta[name="theme-color"]')&&document.querySelector('meta[name="theme-color"]').setAttribute("content","#0d0d0d")},e.activateLightMode=function(){document.documentElement.setAttribute("data-theme","light"),null!==document.querySelector('meta[name="theme-color"]')&&document.querySelector('meta[name="theme-color"]').setAttribute("content","#ffffff")};const t=saveToLocal.get("theme");"dark"===t?activateDarkMode():"light"===t&&activateLightMode();const o=saveToLocal.get("aside-status");void 0!==o&&("hide"===o?document.documentElement.classList.add("hide-aside"):document.documentElement.classList.remove("hide-aside"));/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)&&document.documentElement.classList.add("apple")})(window)</script><link rel="stylesheet" href="https://cdn1.tianli0.top/gh/web-xc/My-blog-CSS/mgi.css"><link rel="stylesheet" href="https://cdn1.tianli0.top/gh/web-xc/My-blog-CSS/mg111.css"><link rel="stylesheet" href="https://npm.elemecdn.com/webxc@1.0.16/css/mg2.css"><link rel="stylesheet" href="https://npm.elemecdn.com/webxc@1.0.11/css/styless.css"><link rel="stylesheet" href="https://npm.elemecdn.com/webxc@1.0.11/css/styles.css"><link rel="stylesheet" href="https://npm.elemecdn.com/webxc@1.0.11/css/font.css"><link rel="stylesheet" href="https://npm.elemecdn.com/webxc@1.0.15/css/font2.css"><link rel="stylesheet" href="https://npm.elemecdn.com/webxc@1.0.12/css/swiper/swiper.min.css" media="print" onload='this.media="all"'><link rel="stylesheet" href="https://npm.elemecdn.com/webxc@1.0.12/css/swiper/swiperstyle.css" media="print" onload='this.media="all"'><meta name="generator" content="Hexo 6.3.0"></head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="https://npm.elemecdn.com/webxc@1.0.0/logo/logo.jpg" onerror='onerror=null,src="https://npm.elemecdn.com/webxc@1.0.2/banner/404.gif"' alt="avatar"></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">95</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">25</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">25</div></a></div><hr><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw iconfont icon-shouye"></i> <span>首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw iconfont icon-shijian"></i> <span>时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw iconfont icon-biaoqian"></i> <span>标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw iconfont icon-fenlei"></i> <span>分类</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw iconfont icon-lianxiwomen"></i> <span>友联</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw iconfont icon-iconzhengli-"></i> <span>关于</span></a></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);"><i class="fa-fw iconfont icon-a-wangzhanchaojilianjiehulianwang"></i> <span>推荐</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" target="_blank" rel="noopener" href="http://www.inode.club/"><i class="fa-fw fa-sharp fa-solid fa-square-rss"></i> <span>程序员指南</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="http://ife.baidu.com/"><i class="fa-fw fa-brands fa-vuejs"></i> <span>前端技术学园</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://www.yuque.com/tademanong/ag7q4n"><i class="fa-fw fa-solid fa-users"></i> <span>前端技术圈</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://www.code-nav.cn/"><i class="fa-fw fa-solid fa-shop"></i> <span>编程导航</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://q.shanyue.tech/"><i class="fa-fw fa-brands fa-square-js"></i> <span>每日一题</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://fanyouf.gitee.io/u1word/#/h5"><i class="fa-fw fa-solid fa-headphones"></i> <span>前端必会单词</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://site.51git.cn/render/gonav/4.html"><i class="fa-fw iconfont icon-wangzhandingzhi"></i> <span>网址导航</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://www.webxc.eu.org/music/"><i class="fa-fw iconfont icon-musical-note"></i> <span>音乐解锁</span></a></li></ul></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image:url('https://cdn1.tianli0.top/gh/web-xc/iMG/postss/ajax.webp')"><nav id="nav"><span id="blog_name"><div class="back-home-button" tabindex="-1"><i class="back-home-button-icon fas fa-grip-vertical"></i><div class="back-menu-list-groups"><div class="back-menu-list-group"><div class="back-menu-list-title">项目</div><div class="back-menu-list"><a class="back-menu-item" href="/" title="前往博客主页" target="_blank" one-link-mark="yes"><img class="back-menu-item-icon" src="https://npm.elemecdn.com/webxc@1.0.0/logo/logo.jpg"><span class="back-menu-item-text">主站</span></a><a class="back-menu-item" href="https://e.webxc.eu.org/" rel="external nofollow" title="前往学习笔记" target="_blank" one-link-mark="yes"><img class="back-menu-item-icon" src="https://npm.elemecdn.com/webxc@1.0.0/logo/logo.jpg"><span class="back-menu-item-text">学习笔记</span></a><a class="back-menu-item" href="https://v.webxc.eu.org/" rel="external nofollow" title="VuePress学习文档" target="_blank" one-link-mark="yes"><img class="back-menu-item-icon" src="https://npm.elemecdn.com/webxc@1.0.0/logo/logo.jpg"><span class="back-menu-item-text">VuePress文档</span></a><a class="back-menu-item" href="https://b.webxc.eu.org/" rel="external nofollow" title="旧站Hexo" target="_blank" one-link-mark="yes"><img class="back-menu-item-icon" src="https://npm.elemecdn.com/webxc@1.0.0/logo/logo.jpg"><span class="back-menu-item-text">旧站Hexo</span></a><a class="back-menu-item" href="https://gridea.webxc.eu.org/" rel="external nofollow" title="Gridea笔记" target="_blank" one-link-mark="yes"><img class="back-menu-item-icon" src="https://npm.elemecdn.com/webxc@1.0.0/logo/logo.jpg"><span class="back-menu-item-text">Gridea笔记</span></a><a class="back-menu-item" href="https://c.webxc.eu.org/" rel="external nofollow" title="魔改Hexo" target="_blank" one-link-mark="yes"><img class="back-menu-item-icon" src="https://npm.elemecdn.com/webxc@1.0.0/logo/logo.jpg"><span class="back-menu-item-text">魔改Hexo</span></a></div></div><div class="back-menu-list-group"><div class="back-menu-list-title">博客镜像</div><div class="back-menu-list"><a class="back-menu-item" href="https://blog.webxc.eu.org/" title="Vercel镜像" target="_blank" rel="noopener nofollow" one-link-mark="yes"><img class="back-menu-item-icon" src="https://npm.elemecdn.com/webxc@1.0.0/logo/logo.jpg"><span class="back-menu-item-text">Vercel镜像</span></a><a class="back-menu-item" href="https://webxc.tk/" title="Netlify镜像" target="_blank" rel="noopener nofollow" one-link-mark="yes"><img class="back-menu-item-icon" src="https://npm.elemecdn.com/webxc@1.0.0/logo/logo.jpg"><span class="back-menu-item-text">Netlify镜像</span></a><a class="back-menu-item" href="https://web-xc.gitee.io/" title="Gitee镜像" target="_blank" rel="noopener nofollow" one-link-mark="yes"><img class="back-menu-item-icon" src="https://npm.elemecdn.com/webxc@1.0.0/logo/logo.jpg"><span class="back-menu-item-text">Gitee镜像</span></a><a class="back-menu-item" href="https://cf.webxc.eu.org/" title="Cloudflare镜像" target="_blank" rel="noopener nofollow" one-link-mark="yes"><img class="back-menu-item-icon" src="https://npm.elemecdn.com/webxc@1.0.0/logo/logo.jpg"><span class="back-menu-item-text">Cloudflare镜像</span></a><a class="back-menu-item" href="https://render.webxc.eu.org/" title="Render镜像" target="_blank" rel="noopener nofollow" one-link-mark="yes"><img class="back-menu-item-icon" src="https://npm.elemecdn.com/webxc@1.0.0/logo/logo.jpg"><span class="back-menu-item-text">Render镜像</span></a></div></div></div></div><a id="site-name" href="/"><div class="title">XC's Blog</div><i class="fa-solid fa-house"></i></a></span><div class="mask-name-container"><center id="name-container"><a id="page-name" href="javascript:btf.scrollToDest(0, 500)">PAGE_NAME</a></center></div><div id="menus"><div class="nav-button" id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i> <span>搜索</span></a></div><div class="nav-button" id="darkmode_navswitch"><a class="darkmode_switchbutton" type="button" title="浅色和深色模式转换" onclick="switchDarkMode()"><i class="fas fa-adjust"></i></a></div><div class="nav-button" id="nav-totop"><a class="totopbtn"><i class="fas fa-arrow-up"></i><span id="percent" onclick="btf.scrollToDest(0,500)">0</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw iconfont icon-shouye"></i> <span>首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw iconfont icon-shijian"></i> <span>时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw iconfont icon-biaoqian"></i> <span>标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw iconfont icon-fenlei"></i> <span>分类</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw iconfont icon-lianxiwomen"></i> <span>友联</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw iconfont icon-iconzhengli-"></i> <span>关于</span></a></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);"><i class="fa-fw iconfont icon-a-wangzhanchaojilianjiehulianwang"></i> <span>推荐</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" target="_blank" rel="noopener" href="http://www.inode.club/"><i class="fa-fw fa-sharp fa-solid fa-square-rss"></i> <span>程序员指南</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="http://ife.baidu.com/"><i class="fa-fw fa-brands fa-vuejs"></i> <span>前端技术学园</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://www.yuque.com/tademanong/ag7q4n"><i class="fa-fw fa-solid fa-users"></i> <span>前端技术圈</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://www.code-nav.cn/"><i class="fa-fw fa-solid fa-shop"></i> <span>编程导航</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://q.shanyue.tech/"><i class="fa-fw fa-brands fa-square-js"></i> <span>每日一题</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://fanyouf.gitee.io/u1word/#/h5"><i class="fa-fw fa-solid fa-headphones"></i> <span>前端必会单词</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://site.51git.cn/render/gonav/4.html"><i class="fa-fw iconfont icon-wangzhandingzhi"></i> <span>网址导航</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://www.webxc.eu.org/music/"><i class="fa-fw iconfont icon-musical-note"></i> <span>音乐解锁</span></a></li></ul></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">Ajax第四天</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2023-06-08T10:00:00.000Z" title="发表于 2023-06-08 10:00:00">2023-06-08</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2023-08-30T18:00:49.013Z" title="更新于 2023-08-30 18:00:49">2023-08-30</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/Ajax%E7%AC%94%E8%AE%B0/">Ajax笔记</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span data-flag-title="Ajax第四天"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="twikoo_visitors"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="Day04-AJAX进阶"><a href="#Day04-AJAX进阶" class="headerlink" title="Day04_AJAX进阶"></a>Day04_AJAX进阶</h1><h2 id="知识点自测"><a href="#知识点自测" class="headerlink" title="知识点自测"></a>知识点自测</h2><ol><li><p>看如下标签回答如下问题？</p><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">select</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">option</span> <span class="attr">value</span>=<span class="string">&quot;北京&quot;</span>&gt;</span>北京市<span class="tag">&lt;/<span class="name">option</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">option</span> <span class="attr">value</span>=<span class="string">&quot;南京&quot;</span>&gt;</span>南京市<span class="tag">&lt;/<span class="name">option</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">option</span> <span class="attr">value</span>=<span class="string">&quot;天津&quot;</span>&gt;</span>天津市<span class="tag">&lt;/<span class="name">option</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">select</span>&gt;</span></span><br></pre></td></tr></table></figure><ul><li><p>当选中第二个 option 时, JS 中获取下拉菜单 select 标签的 value 属性的值是多少?</p><details><summary>答案</summary><ul><li>南京</li></ul></details></li><li><p>页面上看到的是北京, 还是北京市等？</p><details><summary>答案</summary><ul><li>北京市</li></ul></details></li></ul></li><li><p>我给 select 标签的 value 属性赋予”南京”会有什么效果？</p><details><summary>答案</summary><ul><li>什么效果都没有, 没有没有一个option选项的value能匹配</li></ul></details></li></ol><h2 id="目录"><a href="#目录" class="headerlink" title="目录"></a>目录</h2><ul><li>同步代码和异步代码</li><li>回调函数地狱和 Promise 链式调用</li><li>async 和 await 使用</li><li>事件循环-EventLoop</li><li>Promise.all 静态方法</li><li>案例 - 商品分类</li><li>案例 - 学习反馈</li></ul><h2 id="学习目标"><a href="#学习目标" class="headerlink" title="学习目标"></a>学习目标</h2><ol><li>区分异步代码，回调函数地狱问题和所有解决防范（Promise 链式调用）</li><li>掌握 async 和 await 使用</li><li>掌握 EventLoop 的概念</li><li>了解 Promise.all 静态方法作用</li><li>完成省市区切换效果</li></ol><h2 id="01-同步代码和异步代码"><a href="#01-同步代码和异步代码" class="headerlink" title="01.同步代码和异步代码"></a>01.同步代码和异步代码</h2><h3 id="目标"><a href="#目标" class="headerlink" title="目标"></a>目标</h3><ul><li>能够区分出哪些是异步代码</li></ul><h3 id="讲解"><a href="#讲解" class="headerlink" title="讲解"></a>讲解</h3><ol><li><p>同步代码：逐行执行，需原地等待结果后，才继续向下执行</p></li><li><p>异步代码：调用后耗时，不阻塞代码继续执行（不必原地等待），在将来完成后触发回调函数传递结果</p></li><li><p>回答代码打印顺序：发现异步代码接收结果，使用的都是回调函数</p><p><img src="" data-lazy-src="https://yjy-teach-oss.oss-cn-beijing.aliyuncs.com/hm8.1ajax/image-20230222171348399.png" alt="image-20230222171348399"></p></li></ol><h3 id="小结"><a href="#小结" class="headerlink" title="小结"></a>小结</h3><ol><li><p>什么是同步代码?</p><details><summary>答案</summary><ul><li>逐行执行，原地等待结果后，才继续向下执行</li></ul></details></li><li><p>什么是异步代码?</p><details><summary>答案</summary><ul><li>调用后耗时，不阻塞代码执行，将来完成后触发回调函数</li></ul></details></li><li><p>JS 中有哪些异步代码?</p><details><summary>答案</summary><ul><li>setTimeout / setInterval，事件，AJAX</li></ul></details></li><li><p>异步代码如何接收结果?</p><details><summary>答案</summary><ul><li>依靠回调函数来接收</li></ul></details></li></ol><h2 id="02-回调函数地狱"><a href="#02-回调函数地狱" class="headerlink" title="02.回调函数地狱"></a>02.回调函数地狱</h2><h3 id="目标-1"><a href="#目标-1" class="headerlink" title="目标"></a>目标</h3><ul><li>了解回调函数地狱的概念和缺点</li></ul><h3 id="讲解-1"><a href="#讲解-1" class="headerlink" title="讲解"></a>讲解</h3><ol><li><p>需求：展示默认第一个省，第一个城市，第一个地区在下拉菜单中</p><p><img src="" data-lazy-src="https://yjy-teach-oss.oss-cn-beijing.aliyuncs.com/hm8.1ajax/image-20230222173109762.png" alt="image-20230222173109762"></p></li><li><p>概念：在回调函数中嵌套回调函数，一直嵌套下去就形成了回调函数地狱</p></li><li><p>缺点：可读性差，异常无法捕获，耦合性严重，牵一发动全身</p><p><img src="" data-lazy-src="https://yjy-teach-oss.oss-cn-beijing.aliyuncs.com/hm8.1ajax/image-20230222173138836.png" alt="image-20230222173138836"></p></li></ol><h3 id="小结-1"><a href="#小结-1" class="headerlink" title="小结"></a>小结</h3><ol><li><p>什么是回调函数地狱?</p><details><summary>答案</summary><ul><li>在回调函数一直向下嵌套回调函数，形成回调函数地狱</li></ul></details></li><li><p>回调函数地狱问题?</p><details><summary>答案</summary><ul><li>可读性差，异常捕获困难，耦合性严重</li></ul></details></li></ol><h2 id="03-Promise-链式调用"><a href="#03-Promise-链式调用" class="headerlink" title="03.Promise-链式调用"></a>03.Promise-链式调用</h2><h3 id="目标-2"><a href="#目标-2" class="headerlink" title="目标"></a>目标</h3><ul><li>了解 Promise 链式调用特点和语法</li></ul><h3 id="讲解-2"><a href="#讲解-2" class="headerlink" title="讲解"></a>讲解</h3><ol><li><p>概念：依靠 then() 方法会返回一个新生成的 Promise 对象特性，继续串联下一环任务，直到结束</p></li><li><p>细节：then() 回调函数中的返回值，会影响新生成的 Promise 对象最终状态和结果</p></li><li><p>好处：通过链式调用，解决回调函数嵌套问题</p><p><img src="" data-lazy-src="https://yjy-teach-oss.oss-cn-beijing.aliyuncs.com/hm8.1ajax/image-20230222173851738.png" alt="image-20230222173851738"></p></li></ol><h3 id="小结-2"><a href="#小结-2" class="headerlink" title="小结"></a>小结</h3><ol><li><p>什么是 Promise 的链式调用?</p><details><summary>答案</summary><ul><li>使用 then 方法返回新 Promise 对象特性，一直串联下去</li></ul></details></li><li><p>then 回调函数中，return 的值会传给哪里?</p><details><summary>答案</summary><ul><li>传给 then 方法生成的新 Promise 对象</li></ul></details></li><li><p>Promise 链式调用有什么用?</p><details><summary>答案</summary><ul><li>解决回调函数嵌套问题</li></ul></details></li></ol><h2 id="04-Promise-链式调用-解决回调地狱"><a href="#04-Promise-链式调用-解决回调地狱" class="headerlink" title="04.Promise-链式调用_解决回调地狱"></a>04.Promise-链式调用_解决回调地狱</h2><h3 id="目标-3"><a href="#目标-3" class="headerlink" title="目标"></a>目标</h3><ul><li>了解 Promise 链式调用解决回调地狱</li></ul><h3 id="讲解-3"><a href="#讲解-3" class="headerlink" title="讲解"></a>讲解</h3><ol><li><p>目标：使用 Promise 链式调用，解决回调函数地狱问题</p></li><li><p>做法：每个 Promise 对象中管理一个异步任务，用 then 返回 Promise 对象，串联起来</p><p><img src="" data-lazy-src="https://yjy-teach-oss.oss-cn-beijing.aliyuncs.com/hm8.1ajax/image-20230222174946534.png" alt="image-20230222174946534"></p></li></ol><h3 id="小结-3"><a href="#小结-3" class="headerlink" title="小结"></a>小结</h3><ol><li><p>Promise 链式调用如何解决回调函数地狱?</p><details><summary>答案</summary><ul><li>then 的回调函数中 return Promise对象，影响当前新 Promise 对象的值</li></ul></details></li></ol><h2 id="05-async-函数和-await"><a href="#05-async-函数和-await" class="headerlink" title="05.async 函数和 await"></a>05.async 函数和 await</h2><h3 id="目标-4"><a href="#目标-4" class="headerlink" title="目标"></a>目标</h3><ul><li>掌握 async 和 await 语法来编写简洁的异步代码</li></ul><h3 id="讲解-4"><a href="#讲解-4" class="headerlink" title="讲解"></a>讲解</h3><ol><li><p>概念：在 async 函数内，使用 await 关键字取代 then 函数，等待获取 Promise 对象成功状态的结果值</p></li><li><p>做法：使用 async 和 await 解决回调地狱问题</p><p><img src="" data-lazy-src="https://yjy-teach-oss.oss-cn-beijing.aliyuncs.com/hm8.1ajax/image-20230222180035098.png" alt="image-20230222180035098"></p><blockquote><p>使用 await 替代 then 的方法</p></blockquote></li></ol><h3 id="小结-4"><a href="#小结-4" class="headerlink" title="小结"></a>小结</h3><ol><li><p>await 的作用是什么？</p><details><summary>答案</summary><ul><li>替代 then 方法来提取 Promise 对象成功状态的结果</li></ul></details></li></ol><h2 id="06-async-函数和-await-捕获错误"><a href="#06-async-函数和-await-捕获错误" class="headerlink" title="06.async 函数和 await 捕获错误"></a>06.async 函数和 await 捕获错误</h2><h3 id="目标-5"><a href="#目标-5" class="headerlink" title="目标"></a>目标</h3><ul><li>了解用 try catch 捕获同步流程的错误</li></ul><h3 id="讲解-5"><a href="#讲解-5" class="headerlink" title="讲解"></a>讲解</h3><ol><li><p>try 和 catch 的作用：用于捕获错误</p><p><img src="" data-lazy-src="https://yjy-teach-oss.oss-cn-beijing.aliyuncs.com/hm8.1ajax/image-20230222180741620.png" alt="image-20230222180741620"></p><blockquote><p>try 里报错的代码会立刻跳转到 catch 中</p></blockquote></li></ol><h3 id="小结-5"><a href="#小结-5" class="headerlink" title="小结"></a>小结</h3><ol><li><p>try 和 catch 有什么作用？</p><details><summary>答案</summary><ul><li>捕获同步流程的代码报错信息</li></ul></details></li></ol><h2 id="07-事件循环"><a href="#07-事件循环" class="headerlink" title="07.事件循环"></a>07.事件循环</h2><h3 id="目标-6"><a href="#目标-6" class="headerlink" title="目标"></a>目标</h3><ul><li>掌握事件循环模型是如何执行异步代码的</li></ul><h3 id="讲解-6"><a href="#讲解-6" class="headerlink" title="讲解"></a>讲解</h3><ol><li><p>事件循环（EventLoop）：掌握后知道 JS 是如何安排和运行代码的</p><p><img src="" data-lazy-src="https://yjy-teach-oss.oss-cn-beijing.aliyuncs.com/hm8.1ajax/image-20230222181836863.png" alt="image-20230222181836863"></p></li><li><p>作用：事件循环负责执行代码，收集和处理事件以及执行队列中的子任务</p></li><li><p>原因：JavaScript 单线程（某一刻只能执行一行代码），为了让耗时代码不阻塞其他代码运行，设计了事件循环模型</p></li><li><p>概念：执行代码和收集异步任务的模型，在调用栈空闲，反复调用任务队列里回调函数的执行机制，就叫事件循环</p><p><img src="" data-lazy-src="https://yjy-teach-oss.oss-cn-beijing.aliyuncs.com/hm8.1ajax/image-20230222182338992.png" alt="image-20230222182338992"></p></li></ol><h3 id="小结-6"><a href="#小结-6" class="headerlink" title="小结"></a>小结</h3><ol><li><p>什么是事件循环？</p><details><summary>答案</summary><ul><li>执行代码和收集异步任务，在调用栈空闲时，反复调用任务队列里回调函数执行机制</li></ul></details></li><li><p>为什么有事件循环？</p><details><summary>答案</summary><ul><li>JavaScript 是单线程的，为了不阻塞 JS 引擎，设计执行代码的模型</li></ul></details></li><li><p>JavaScript 内代码如何执行？</p><details><summary>答案</summary><ul><li>执行同步代码，遇到异步代码交给宿主浏览器环境执行 异步有了结果后，把回调函数放入任务队列排队 当调用栈空闲后，反复调用任务队列里的回调函数</li></ul></details></li></ol><h2 id="08-事件循环-练习"><a href="#08-事件循环-练习" class="headerlink" title="08.事件循环-练习"></a>08.事件循环-练习</h2><h3 id="目标-7"><a href="#目标-7" class="headerlink" title="目标"></a>目标</h3><ul><li>了解事件循环的执行模型</li></ul><h3 id="讲解-7"><a href="#讲解-7" class="headerlink" title="讲解"></a>讲解</h3><ol><li><p>使用模型，分析代码执行过程</p><p><img src="" data-lazy-src="https://yjy-teach-oss.oss-cn-beijing.aliyuncs.com/hm8.1ajax/image-20230222183656761.png" alt="image-20230222183656761"></p></li></ol><h3 id="小结-7"><a href="#小结-7" class="headerlink" title="小结"></a>小结</h3><p>暂无</p><h2 id="09-宏任务与微任务"><a href="#09-宏任务与微任务" class="headerlink" title="09.宏任务与微任务"></a>09.宏任务与微任务</h2><h3 id="目标-8"><a href="#目标-8" class="headerlink" title="目标"></a>目标</h3><ul><li>掌握微任务和宏任务的概念和区分</li></ul><h3 id="讲解-8"><a href="#讲解-8" class="headerlink" title="讲解"></a>讲解</h3><ol><li><p>ES6 之后引入了 Promise 对象， 让 JS 引擎也可以发起异步任务</p></li><li><p>异步任务划分为了</p><ul><li>宏任务：由浏览器环境执行的异步代码</li><li>微任务：由 JS 引擎环境执行的异步代码</li></ul></li><li><p>微任务和宏任务划分：</p><p><img src="" data-lazy-src="https://yjy-teach-oss.oss-cn-beijing.aliyuncs.com/hm8.1ajax/image-20230222184920343.png" alt="image-20230222184920343"></p></li><li><p>事件循环模型</p><p><img src="" data-lazy-src="https://yjy-teach-oss.oss-cn-beijing.aliyuncs.com/hm8.1ajax/image-20230222184949605.png" alt="image-20230222184949605"></p></li></ol><h3 id="小结-8"><a href="#小结-8" class="headerlink" title="小结"></a>小结</h3><ol><li><p>什么是宏任务？</p><details><summary>答案</summary><ul><li>浏览器执行的异步代码 例如：JS 执行脚本事件，setTimeout/setInterval，AJAX请求完成事件，用户交互事件等</li></ul></details></li><li><p>什么是微任务？</p><details><summary>答案</summary><ul><li>JS 引擎执行的异步代码 例如：Promise对象.then()的回调</li></ul></details></li><li><p>JavaScript 内代码如何执行？</p><details><summary>答案</summary><ul><li>执行第一个 script 脚本事件宏任务，里面同步代码 遇到 宏任务/微任务 交给宿主环境，有结果回调函数进入对应队列 当执行栈空闲时，清空微任务队列，再执行下一个宏任务，从1再来</li></ul></details></li></ol><p><img src="" data-lazy-src="https://yjy-teach-oss.oss-cn-beijing.aliyuncs.com/hm8.1ajax/image-20230222185205193.png" alt="image-20230222185205193"></p><h2 id="10-事件循环-经典面试题"><a href="#10-事件循环-经典面试题" class="headerlink" title="10.事件循环 - 经典面试题"></a>10.事件循环 - 经典面试题</h2><h3 id="目标-9"><a href="#目标-9" class="headerlink" title="目标"></a>目标</h3><ul><li>锻炼事件循环模型的使用</li></ul><h3 id="讲解-9"><a href="#讲解-9" class="headerlink" title="讲解"></a>讲解</h3><ol><li><p>请切换到对应配套代码，查看具体代码，并回答打印顺序</p><p><img src="" data-lazy-src="https://yjy-teach-oss.oss-cn-beijing.aliyuncs.com/hm8.1ajax/image-20230222185939276.png" alt="image-20230222185939276"></p></li></ol><h3 id="小结-9"><a href="#小结-9" class="headerlink" title="小结"></a>小结</h3><p>暂无</p><h2 id="11-Promise-all-静态方法"><a href="#11-Promise-all-静态方法" class="headerlink" title="11.Promise.all 静态方法"></a>11.Promise.all 静态方法</h2><h3 id="目标-10"><a href="#目标-10" class="headerlink" title="目标"></a>目标</h3><ul><li>了解 Promise.all 作用和使用场景</li></ul><h3 id="讲解-10"><a href="#讲解-10" class="headerlink" title="讲解"></a>讲解</h3><ol><li><p>概念：合并多个 Promise 对象，等待所有同时成功完成（或某一个失败），做后续逻辑</p><p><img src="" data-lazy-src="https://yjy-teach-oss.oss-cn-beijing.aliyuncs.com/hm8.1ajax/image-20230222190117045.png" alt="image-20230222190117045"></p></li><li><p>语法：</p><p><img src="" data-lazy-src="https://yjy-teach-oss.oss-cn-beijing.aliyuncs.com/hm8.1ajax/image-20230222190153424.png" alt="image-20230222190153424"></p></li><li><p>需求：同时请求“北京”，“上海”，“广州”，“深圳”的天气并在网页尽可能同时显示</p><p><img src="" data-lazy-src="https://yjy-teach-oss.oss-cn-beijing.aliyuncs.com/hm8.1ajax/image-20230222190230351.png" alt="image-20230222190230351"></p></li></ol><h3 id="小结-10"><a href="#小结-10" class="headerlink" title="小结"></a>小结</h3><ol><li><p>Promise.all 什么时候使用？</p><details><summary>答案</summary><ul><li>合并多个 Promise 对象并等待所有同时成功的结果，如果有一个报错就会最终为失败状态，当需要同时渲染多个接口数据同时到网页上时使用</li></ul></details></li></ol><h2 id="12-案例-商品分类"><a href="#12-案例-商品分类" class="headerlink" title="12.案例-商品分类"></a>12.案例-商品分类</h2><h3 id="目标-11"><a href="#目标-11" class="headerlink" title="目标"></a>目标</h3><ul><li>完成商品分类效果</li></ul><h3 id="讲解-11"><a href="#讲解-11" class="headerlink" title="讲解"></a>讲解</h3><ol><li><p>需求：尽可能同时展示所有商品分类到页面上</p><p><img src="" data-lazy-src="https://yjy-teach-oss.oss-cn-beijing.aliyuncs.com/hm8.1ajax/image-20230222191151264.png" alt="image-20230222191151264"></p></li><li><p>步骤：</p><p>1.获取所有的一级分类数据</p><p>2.遍历id，创建获取二级分类请求</p><p>3.合并所有二级分类Promise对象</p><p>4.等待同时成功，开始渲染页面</p></li></ol><h3 id="小结-11"><a href="#小结-11" class="headerlink" title="小结"></a>小结</h3><p>暂无</p><h2 id="13-案例-学习反馈-省市区切换"><a href="#13-案例-学习反馈-省市区切换" class="headerlink" title="13.案例-学习反馈-省市区切换"></a>13.案例-学习反馈-省市区切换</h2><h3 id="目标-12"><a href="#目标-12" class="headerlink" title="目标"></a>目标</h3><ul><li>完成省市区切换效果</li></ul><h3 id="讲解-12"><a href="#讲解-12" class="headerlink" title="讲解"></a>讲解</h3><ol><li><p>需求：完成省市区切换效果</p><p><img src="" data-lazy-src="https://yjy-teach-oss.oss-cn-beijing.aliyuncs.com/hm8.1ajax/image-20230222191239971.png" alt="image-20230222191239971"></p></li><li><p>步骤：</p><p>1.设置省份数据到下拉菜单</p><p>2.切换省份，设置城市数据到下拉菜单，并清空地区下拉菜单</p><p>3.切换城市，设置地区数据到下拉菜单</p></li></ol><h3 id="小结-12"><a href="#小结-12" class="headerlink" title="小结"></a>小结</h3><p>暂无</p><h2 id="14-案例-学习反馈-数据提交"><a href="#14-案例-学习反馈-数据提交" class="headerlink" title="14.案例-学习反馈-数据提交"></a>14.案例-学习反馈-数据提交</h2><h3 id="目标-13"><a href="#目标-13" class="headerlink" title="目标"></a>目标</h3><ul><li>完成学习反馈数据提交</li></ul><h3 id="讲解-13"><a href="#讲解-13" class="headerlink" title="讲解"></a>讲解</h3><ol><li><p>需求：收集学习反馈数据，提交保存</p><p><img src="" data-lazy-src="https://yjy-teach-oss.oss-cn-beijing.aliyuncs.com/hm8.1ajax/image-20230222191239971.png" alt="image-20230222191239971"></p></li><li><p>步骤：</p><p>1.监听提交按钮的点击事件</p><p>2.依靠插件收集表单数据</p><p>3.基于 axios 提交保存，显示结果</p></li></ol><h3 id="小结-13"><a href="#小结-13" class="headerlink" title="小结"></a>小结</h3><p>暂无</p><h2 id="今日重点-必须会"><a href="#今日重点-必须会" class="headerlink" title="今日重点(必须会)"></a>今日重点(必须会)</h2><ol><li><p>掌握 async 和 await 的使用</p></li><li><p>理解 EventLoop 和宏任务微任务执行顺序</p></li><li><p>了解 Promise.all 的作用和使用场景</p></li><li><p>完成案例-学习反馈</p></li></ol><h2 id="今日作业-必完成"><a href="#今日作业-必完成" class="headerlink" title="今日作业(必完成)"></a>今日作业(必完成)</h2><p>参考作业文件夹里md文档的要求</p><h2 id="参考文献"><a href="#参考文献" class="headerlink" title="参考文献"></a>参考文献</h2><ol><li><a target="_blank" rel="noopener" href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Statements/async_function#%E5%B0%9D%E8%AF%95%E4%B8%80%E4%B8%8B">async和await的mdn讲解</a></li></ol><h1 id="Day04-AJAX进阶-1"><a href="#Day04-AJAX进阶-1" class="headerlink" title="Day04_AJAX进阶"></a>Day04_AJAX进阶</h1><h2 id="客观题"><a href="#客观题" class="headerlink" title="客观题"></a>客观题</h2><ul><li><p>参考客观题目录下的excel</p></li><li><p>在线直接答题：<a target="_blank" rel="noopener" href="https://ks.wjx.top/vm/miNp0Vr.aspx#">https://ks.wjx.top/vm/miNp0Vr.aspx#</a></p><blockquote><p>ps：本测试链接来自问卷星，请不要轻信问卷星广告！</p></blockquote></li></ul><h2 id="主观题"><a href="#主观题" class="headerlink" title="主观题"></a>主观题</h2><h3 id="作业1-3-事件循环面试题"><a href="#作业1-3-事件循环面试题" class="headerlink" title="作业1-3 事件循环面试题"></a>作业1-3 事件循环面试题</h3><p>请查看配套文件夹里代码运行的结果</p><h3 id="作业4-评论列表"><a href="#作业4-评论列表" class="headerlink" title="作业4 - 评论列表"></a>作业4 - 评论列表</h3><p>目标：完成如下评论列表效果</p><p><img src="" data-lazy-src="https://yjy-teach-oss.oss-cn-beijing.aliyuncs.com/hm8.1ajax/cmt-list.gif" alt="cmt-list">要求：</p><ol><li>默认上来展示所有评论列表数据（注意不区分用户了）感受下大家数据互相影响，也可以看到别人评论</li><li>新增评论功能</li><li>删除评论功能</li><li>分页切换评论列表数据功能</li><li>删除最后一条评论，列表要自动回到上一页</li></ol><p>接口文档：<a target="_blank" rel="noopener" href="https://www.apifox.cn/apidoc/project-1937884/api-64282606">https://www.apifox.cn/apidoc/project-1937884/api-64282606</a></p><p>配套资料：配套标签和样式在文件夹内</p><h2 id="排错题"><a href="#排错题" class="headerlink" title="排错题"></a>排错题</h2><p>配套文件夹内的《案例-学习反馈》里面有 3 处错误，请帮帮这位同学实现更换网站背景的效果吧</p><h2 id="面试题-自行扩展"><a href="#面试题-自行扩展" class="headerlink" title="面试题(自行扩展)"></a>面试题(自行扩展)</h2><ol><li><p>你是怎么理解事件代理的?</p><p><a target="_blank" rel="noopener" href="https://lamphc.github.io/fe-up/#/JavaScript/event_agent?id=%e9%9d%a2%e8%af%95%e5%ae%98%ef%bc%9a%e8%a7%a3%e9%87%8a%e4%b8%8b%e4%bb%80%e4%b9%88%e6%98%af%e4%ba%8b%e4%bb%b6%e4%bb%a3%e7%90%86%ef%bc%9f%e5%ba%94%e7%94%a8%e5%9c%ba%e6%99%af%ef%bc%9f">参考文档</a></p></li><li><p>说说你对事件循环的理解？</p><p><a target="_blank" rel="noopener" href="https://lamphc.github.io/fe-up/#/JavaScript/event_loop?id=%e9%9d%a2%e8%af%95%e5%ae%98%ef%bc%9a%e8%af%b4%e8%af%b4%e4%bd%a0%e5%af%b9%e4%ba%8b%e4%bb%b6%e5%be%aa%e7%8e%af%e7%9a%84%e7%90%86%e8%a7%a3">参考文档</a></p></li></ol></article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">本文作者:</span> <span class="post-copyright-info"><a href="https://webxc.eu.org">XC's Blog</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">本文链接:</span> <span class="post-copyright-info"><a href="https://webxc.eu.org/post/or01/">https://webxc.eu.org/post/or01/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明:</span> <span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://webxc.eu.org" target="_blank">XC's Blog</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/Ajax%E7%AC%94%E8%AE%B0/">Ajax笔记</a></div><div class="post_share"><div class="social-share" data-image="https://cdn1.tianli0.top/gh/web-xc/iMG/postss/ajax.webp" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://npm.elemecdn.com/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload='this.media="all"'><script src="https://npm.elemecdn.com/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><div class="post-reward"><div class="reward-button"><i class="fas fa-qrcode"></i> 打赏</div><div class="reward-main"><ul class="reward-all"><li class="reward-item"><a href="https://npm.elemecdn.com/webxc@1.0.0/lxfs/wechat.png" target="_blank"><img class="post-qr-code-img" src="https://npm.elemecdn.com/webxc@1.0.0/lxfs/wechat.png" alt="Wechat"></a><div class="post-qr-code-desc">Wechat</div></li><li class="reward-item"><a href="https://npm.elemecdn.com/webxc@1.0.0/lxfs/alipay.jpg" target="_blank"><img class="post-qr-code-img" src="https://npm.elemecdn.com/webxc@1.0.0/lxfs/alipay.jpg" alt="Alipay"></a><div class="post-qr-code-desc">Alipay</div></li></ul></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/post/fs67/"><img class="prev-cover" src="https://cdn1.tianli0.top/gh/web-xc/iMG/postss/ajax.webp" onerror='onerror=null,src="https://npm.elemecdn.com/webxc@1.0.2/banner/404.gif"' alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇文章</div><div class="prev_info">Ajax第三天</div></div></a></div><div class="next-post pull-right"><a href="/post/pr67/"><img class="next-cover" src="https://cdn1.tianli0.top/gh/web-xc/iMG/postss/promise.webp" onerror='onerror=null,src="https://npm.elemecdn.com/webxc@1.0.2/banner/404.gif"' alt="cover of next post"><div class="pagination-info"><div class="label">下一篇文章</div><div class="next_info">ES6-Promise语法与原理</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><div><a href="/post/fs67/" title="Ajax第三天"><img class="cover" src="https://cdn1.tianli0.top/gh/web-xc/iMG/postss/ajax.webp" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-06-07</div><div class="title">Ajax第三天</div></div></a></div><div><a href="/post/pr67/" title="ES6-Promise语法与原理"><img class="cover" src="https://cdn1.tianli0.top/gh/web-xc/iMG/postss/promise.webp" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-06-11</div><div class="title">ES6-Promise语法与原理</div></div></a></div><div><a href="/post/re32/" title="黑马头条-数据管理平台"><img class="cover" src="https://cdn1.tianli0.top/gh/web-xc/iMG/postss/ajax.webp" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-06-15</div><div class="title">黑马头条-数据管理平台</div></div></a></div></div></div><hr><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i> <span>评论</span></div></div><div class="comment-wrap"><div><div id="twikoo-wrap"></div></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="https://npm.elemecdn.com/webxc@1.0.0/logo/logo.jpg" onerror='this.onerror=null,this.src="https://npm.elemecdn.com/webxc@1.0.2/banner/404.gif"' alt="avatar"></div><div class="author-info__name">XC's Blog</div><div class="author-info__description">XC's Blog 记录生活和学习文章</div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">95</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">25</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">25</div></a></div><div class="card-info-social-icons is-center"><a class="social-icon" href="https://tenapi.cn/qqzlk/?qq=2848141597" target="_blank" title="QQ"><i class="iconfont icon-QQ"></i></a><a class="social-icon" href="https://npm.elemecdn.com/webxc@1.0.0/lxfs/wechat.jpg" target="_blank" title="微信"><i class="iconfont icon-weixin"></i></a><a class="social-icon" href="https://github.com/web-xc" target="_blank" title="Github"><i class="iconfont icon-github"></i></a><a class="social-icon" href="https://space.bilibili.com/2134826455" target="_blank" title="BiliBili"><i class="iconfont icon-bilibili"></i></a><a class="social-icon" href="https://music.163.com/#/user/home?id=323682437" target="_blank" title="网易云音乐"><i class="iconfont icon-wyy"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">原网站因使用.ml域名被回收, 再加上本人因学习原因, 没怎么打理博客, 使用了https://webxc.eu.org域名来维持博客运行, 如果有加友联的朋友们, 去友联页看信息即可, 如果原来有加过的, 麻烦在原来域名后缀改一下(.ml ==> .eu.org)就行, 博客写的太乱了, 没时间打理, 兄弟们谅解😁😁~~</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#Day04-AJAX%E8%BF%9B%E9%98%B6"><span class="toc-number">1.</span> <span class="toc-text">Day04_AJAX进阶</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%9F%A5%E8%AF%86%E7%82%B9%E8%87%AA%E6%B5%8B"><span class="toc-number">1.1.</span> <span class="toc-text">知识点自测</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%9B%AE%E5%BD%95"><span class="toc-number">1.2.</span> <span class="toc-text">目录</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%AD%A6%E4%B9%A0%E7%9B%AE%E6%A0%87"><span class="toc-number">1.3.</span> <span class="toc-text">学习目标</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#01-%E5%90%8C%E6%AD%A5%E4%BB%A3%E7%A0%81%E5%92%8C%E5%BC%82%E6%AD%A5%E4%BB%A3%E7%A0%81"><span class="toc-number">1.4.</span> <span class="toc-text">01.同步代码和异步代码</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%9B%AE%E6%A0%87"><span class="toc-number">1.4.1.</span> <span class="toc-text">目标</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%AE%B2%E8%A7%A3"><span class="toc-number">1.4.2.</span> <span class="toc-text">讲解</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%B0%8F%E7%BB%93"><span class="toc-number">1.4.3.</span> <span class="toc-text">小结</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#02-%E5%9B%9E%E8%B0%83%E5%87%BD%E6%95%B0%E5%9C%B0%E7%8B%B1"><span class="toc-number">1.5.</span> <span class="toc-text">02.回调函数地狱</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%9B%AE%E6%A0%87-1"><span class="toc-number">1.5.1.</span> <span class="toc-text">目标</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%AE%B2%E8%A7%A3-1"><span class="toc-number">1.5.2.</span> <span class="toc-text">讲解</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%B0%8F%E7%BB%93-1"><span class="toc-number">1.5.3.</span> <span class="toc-text">小结</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#03-Promise-%E9%93%BE%E5%BC%8F%E8%B0%83%E7%94%A8"><span class="toc-number">1.6.</span> <span class="toc-text">03.Promise-链式调用</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%9B%AE%E6%A0%87-2"><span class="toc-number">1.6.1.</span> <span class="toc-text">目标</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%AE%B2%E8%A7%A3-2"><span class="toc-number">1.6.2.</span> <span class="toc-text">讲解</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%B0%8F%E7%BB%93-2"><span class="toc-number">1.6.3.</span> <span class="toc-text">小结</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#04-Promise-%E9%93%BE%E5%BC%8F%E8%B0%83%E7%94%A8-%E8%A7%A3%E5%86%B3%E5%9B%9E%E8%B0%83%E5%9C%B0%E7%8B%B1"><span class="toc-number">1.7.</span> <span class="toc-text">04.Promise-链式调用_解决回调地狱</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%9B%AE%E6%A0%87-3"><span class="toc-number">1.7.1.</span> <span class="toc-text">目标</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%AE%B2%E8%A7%A3-3"><span class="toc-number">1.7.2.</span> <span class="toc-text">讲解</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%B0%8F%E7%BB%93-3"><span class="toc-number">1.7.3.</span> <span class="toc-text">小结</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#05-async-%E5%87%BD%E6%95%B0%E5%92%8C-await"><span class="toc-number">1.8.</span> <span class="toc-text">05.async 函数和 await</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%9B%AE%E6%A0%87-4"><span class="toc-number">1.8.1.</span> <span class="toc-text">目标</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%AE%B2%E8%A7%A3-4"><span class="toc-number">1.8.2.</span> <span class="toc-text">讲解</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%B0%8F%E7%BB%93-4"><span class="toc-number">1.8.3.</span> <span class="toc-text">小结</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#06-async-%E5%87%BD%E6%95%B0%E5%92%8C-await-%E6%8D%95%E8%8E%B7%E9%94%99%E8%AF%AF"><span class="toc-number">1.9.</span> <span class="toc-text">06.async 函数和 await 捕获错误</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%9B%AE%E6%A0%87-5"><span class="toc-number">1.9.1.</span> <span class="toc-text">目标</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%AE%B2%E8%A7%A3-5"><span class="toc-number">1.9.2.</span> <span class="toc-text">讲解</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%B0%8F%E7%BB%93-5"><span class="toc-number">1.9.3.</span> <span class="toc-text">小结</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#07-%E4%BA%8B%E4%BB%B6%E5%BE%AA%E7%8E%AF"><span class="toc-number">1.10.</span> <span class="toc-text">07.事件循环</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%9B%AE%E6%A0%87-6"><span class="toc-number">1.10.1.</span> <span class="toc-text">目标</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%AE%B2%E8%A7%A3-6"><span class="toc-number">1.10.2.</span> <span class="toc-text">讲解</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%B0%8F%E7%BB%93-6"><span class="toc-number">1.10.3.</span> <span class="toc-text">小结</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#08-%E4%BA%8B%E4%BB%B6%E5%BE%AA%E7%8E%AF-%E7%BB%83%E4%B9%A0"><span class="toc-number">1.11.</span> <span class="toc-text">08.事件循环-练习</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%9B%AE%E6%A0%87-7"><span class="toc-number">1.11.1.</span> <span class="toc-text">目标</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%AE%B2%E8%A7%A3-7"><span class="toc-number">1.11.2.</span> <span class="toc-text">讲解</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%B0%8F%E7%BB%93-7"><span class="toc-number">1.11.3.</span> <span class="toc-text">小结</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#09-%E5%AE%8F%E4%BB%BB%E5%8A%A1%E4%B8%8E%E5%BE%AE%E4%BB%BB%E5%8A%A1"><span class="toc-number">1.12.</span> <span class="toc-text">09.宏任务与微任务</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%9B%AE%E6%A0%87-8"><span class="toc-number">1.12.1.</span> <span class="toc-text">目标</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%AE%B2%E8%A7%A3-8"><span class="toc-number">1.12.2.</span> <span class="toc-text">讲解</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%B0%8F%E7%BB%93-8"><span class="toc-number">1.12.3.</span> <span class="toc-text">小结</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#10-%E4%BA%8B%E4%BB%B6%E5%BE%AA%E7%8E%AF-%E7%BB%8F%E5%85%B8%E9%9D%A2%E8%AF%95%E9%A2%98"><span class="toc-number">1.13.</span> <span class="toc-text">10.事件循环 - 经典面试题</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%9B%AE%E6%A0%87-9"><span class="toc-number">1.13.1.</span> <span class="toc-text">目标</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%AE%B2%E8%A7%A3-9"><span class="toc-number">1.13.2.</span> <span class="toc-text">讲解</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%B0%8F%E7%BB%93-9"><span class="toc-number">1.13.3.</span> <span class="toc-text">小结</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#11-Promise-all-%E9%9D%99%E6%80%81%E6%96%B9%E6%B3%95"><span class="toc-number">1.14.</span> <span class="toc-text">11.Promise.all 静态方法</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%9B%AE%E6%A0%87-10"><span class="toc-number">1.14.1.</span> <span class="toc-text">目标</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%AE%B2%E8%A7%A3-10"><span class="toc-number">1.14.2.</span> <span class="toc-text">讲解</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%B0%8F%E7%BB%93-10"><span class="toc-number">1.14.3.</span> <span class="toc-text">小结</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#12-%E6%A1%88%E4%BE%8B-%E5%95%86%E5%93%81%E5%88%86%E7%B1%BB"><span class="toc-number">1.15.</span> <span class="toc-text">12.案例-商品分类</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%9B%AE%E6%A0%87-11"><span class="toc-number">1.15.1.</span> <span class="toc-text">目标</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%AE%B2%E8%A7%A3-11"><span class="toc-number">1.15.2.</span> <span class="toc-text">讲解</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%B0%8F%E7%BB%93-11"><span class="toc-number">1.15.3.</span> <span class="toc-text">小结</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#13-%E6%A1%88%E4%BE%8B-%E5%AD%A6%E4%B9%A0%E5%8F%8D%E9%A6%88-%E7%9C%81%E5%B8%82%E5%8C%BA%E5%88%87%E6%8D%A2"><span class="toc-number">1.16.</span> <span class="toc-text">13.案例-学习反馈-省市区切换</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%9B%AE%E6%A0%87-12"><span class="toc-number">1.16.1.</span> <span class="toc-text">目标</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%AE%B2%E8%A7%A3-12"><span class="toc-number">1.16.2.</span> <span class="toc-text">讲解</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%B0%8F%E7%BB%93-12"><span class="toc-number">1.16.3.</span> <span class="toc-text">小结</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#14-%E6%A1%88%E4%BE%8B-%E5%AD%A6%E4%B9%A0%E5%8F%8D%E9%A6%88-%E6%95%B0%E6%8D%AE%E6%8F%90%E4%BA%A4"><span class="toc-number">1.17.</span> <span class="toc-text">14.案例-学习反馈-数据提交</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%9B%AE%E6%A0%87-13"><span class="toc-number">1.17.1.</span> <span class="toc-text">目标</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%AE%B2%E8%A7%A3-13"><span class="toc-number">1.17.2.</span> <span class="toc-text">讲解</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%B0%8F%E7%BB%93-13"><span class="toc-number">1.17.3.</span> <span class="toc-text">小结</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BB%8A%E6%97%A5%E9%87%8D%E7%82%B9-%E5%BF%85%E9%A1%BB%E4%BC%9A"><span class="toc-number">1.18.</span> <span class="toc-text">今日重点(必须会)</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BB%8A%E6%97%A5%E4%BD%9C%E4%B8%9A-%E5%BF%85%E5%AE%8C%E6%88%90"><span class="toc-number">1.19.</span> <span class="toc-text">今日作业(必完成)</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%8F%82%E8%80%83%E6%96%87%E7%8C%AE"><span class="toc-number">1.20.</span> <span class="toc-text">参考文献</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#Day04-AJAX%E8%BF%9B%E9%98%B6-1"><span class="toc-number">2.</span> <span class="toc-text">Day04_AJAX进阶</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%AE%A2%E8%A7%82%E9%A2%98"><span class="toc-number">2.1.</span> <span class="toc-text">客观题</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%B8%BB%E8%A7%82%E9%A2%98"><span class="toc-number">2.2.</span> <span class="toc-text">主观题</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BD%9C%E4%B8%9A1-3-%E4%BA%8B%E4%BB%B6%E5%BE%AA%E7%8E%AF%E9%9D%A2%E8%AF%95%E9%A2%98"><span class="toc-number">2.2.1.</span> <span class="toc-text">作业1-3 事件循环面试题</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BD%9C%E4%B8%9A4-%E8%AF%84%E8%AE%BA%E5%88%97%E8%A1%A8"><span class="toc-number">2.2.2.</span> <span class="toc-text">作业4 - 评论列表</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%8E%92%E9%94%99%E9%A2%98"><span class="toc-number">2.3.</span> <span class="toc-text">排错题</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%9D%A2%E8%AF%95%E9%A2%98-%E8%87%AA%E8%A1%8C%E6%89%A9%E5%B1%95"><span class="toc-number">2.4.</span> <span class="toc-text">面试题(自行扩展)</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/post/ds2s/" title="整个前端面试题"><img src="https://cdn1.tianli0.top/gh/web-xc/iMG/postss/vue.png" onerror='this.onerror=null,this.src="https://npm.elemecdn.com/webxc@1.0.2/banner/404.gif"' alt="整个前端面试题"></a><div class="content"><a class="title" href="/post/ds2s/" title="整个前端面试题">整个前端面试题</a><time datetime="2023-08-31T02:00:00.000Z" title="发表于 2023-08-31 02:00:00">2023-08-31</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/post/ds23/" title="常见前端面试题"><img src="https://cdn1.tianli0.top/gh/web-xc/iMG/postss/vue.png" onerror='this.onerror=null,this.src="https://npm.elemecdn.com/webxc@1.0.2/banner/404.gif"' alt="常见前端面试题"></a><div class="content"><a class="title" href="/post/ds23/" title="常见前端面试题">常见前端面试题</a><time datetime="2023-08-28T18:30:00.000Z" title="发表于 2023-08-28 18:30:00">2023-08-28</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/post/fe33/" title="硅谷甄选运营平台"><img src="https://cdn1.tianli0.top/gh/web-xc/iMG/postss/vue.png" onerror='this.onerror=null,this.src="https://npm.elemecdn.com/webxc@1.0.2/banner/404.gif"' alt="硅谷甄选运营平台"></a><div class="content"><a class="title" href="/post/fe33/" title="硅谷甄选运营平台">硅谷甄选运营平台</a><time datetime="2023-07-26T03:55:00.000Z" title="发表于 2023-07-26 03:55:00">2023-07-26</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2021 - 2023 By XC's Blog</div><div class="framework-info"><span></span> <a target="_blank" rel="noopener" href="https://icp.gov.moe/?keyword=20235221">萌ICP备20235221号</a><span class="footer-separator">|</span><span></span> <a target="_blank" rel="noopener" href="https://icp.gov.moe/">萌ICP查询</a><div id="running-time"></div></div><script>setInterval((()=>{let e=Math.round(new Date("2021-11-21 01:35:06").getTime()/1e3),t=Math.round(((new Date).getTime()+288e5)/1e3)-e,n=new Array(0,0,0,0,0);t>=31536e3&&(n[0]=parseInt(t/31536e3),t%=31536e3),t>=86400&&(n[1]=parseInt(t/86400),t%=86400),t>=3600&&(n[2]=parseInt(t/3600),t%=3600),t>=60&&(n[3]=parseInt(t/60),t%=60),t>0&&(n[4]=t),currentTimeHtml="本站已安全运行 "+n[0]+" 年 "+n[1]+" 天 "+n[2]+" 时 "+n[3]+" 分 "+n[4]+" 秒",document.getElementById("running-time").innerHTML=currentTimeHtml}),1e3)</script></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><a id="to_comment" href="#post-comment" title="直达评论"><i class="fas fa-comments"></i></a><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i><span id="percent">0<span>%</span></span></button><button id="go-down" type="button" title="直达底部" onclick="btf.scrollToDest(document.body.scrollHeight,500)"><i class="fas fa-arrow-down"></i></button></div></div><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i> <span>正在载入文件,请稍后</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"></div></div><hr><div id="local-search-results"></div></div></div><div id="search-mask"></div></div><div><script src="https://npm.elemecdn.com/hexo-theme-butterfly/source/js/utils.js"></script><script src="https://npm.elemecdn.com/hexo-theme-butterfly@4.4.0/source/js/main.js"></script><script src="https://npm.elemecdn.com/@fancyapps/ui/dist/fancybox.umd.js"></script><script src="https://npm.elemecdn.com/instant.page/instantpage.js" type="module"></script><script src="https://npm.elemecdn.com/vanilla-lazyload/dist/lazyload.iife.min.js"></script><script src="https://npm.elemecdn.com/node-snackbar/dist/snackbar.min.js"></script><script src="https://npm.elemecdn.com/hexo-theme-butterfly/source/js/search/local-search.js"></script><div class="js-pjax"><script>(()=>{const e=document.querySelectorAll("#article-container .mermaid-wrap");if(e.length){window.runMermaid=()=>{window.loadMermaid=!0;const t="dark"===document.documentElement.getAttribute("data-theme")?"dark":"default";Array.from(e).forEach(((e,n)=>{const d=e.firstElementChild,r="mermaid-"+n,m="%%{init:{ 'theme':'"+t+"'}}%%\n"+d.textContent;mermaid.mermaidAPI.render(r,m,(e=>{d.insertAdjacentHTML("afterend",e)}))}))};const t=()=>{window.loadMermaid?runMermaid():getScript("https://npm.elemecdn.com/mermaid/dist/mermaid.min.js").then(runMermaid)};window.pjax?t():document.addEventListener("DOMContentLoaded",t)}})()</script><script>(()=>{const o=()=>{twikoo.init(Object.assign({el:"#twikoo-wrap",envId:"https://blog2.webxc.eu.org/",region:"",onCommentLoaded:function(){btf.loadLightbox(document.querySelectorAll("#twikoo .tk-content img:not(.tk-owo-emotion)"))}},null))},t=()=>{"object"!=typeof twikoo?getScript("https://npm.elemecdn.com/twikoo@1.6.16/dist/twikoo.all.min.js").then(o):setTimeout(o,0)};t()})()</script></div><script data-pjax="false" defer src="https://npm.elemecdn.com/webxc@1.0.16/css/style.js"></script><script defer src="https://npm.elemecdn.com/hexo-theme-butterfly@4.4.0/source/js/search/local-search.js"></scrip><script src="https://npm.elemecdn.com/butterfly-extsrc/dist/activate-power-mode.min.js"></script><script>POWERMODE.colorful=!0,POWERMODE.shake=!0,POWERMODE.mobile=!0,document.body.addEventListener("input",POWERMODE)</script><script src="https://npm.elemecdn.com/pjax@0.2.8/pjax.min.js"></script><script>let pjaxSelectors=["head > title","#config-diff","#body-wrap","#rightside-config-hide","#rightside-config-show",".js-pjax",".tk-comments-container"];var pjax=new Pjax({elements:'a:not([target="_blank"])',selectors:pjaxSelectors,cacheBust:!1,analytics:!1,scrollRestoration:!1});document.addEventListener("pjax:send",(function(){if(window.tocScrollFn&&window.removeEventListener("scroll",window.tocScrollFn),window.scrollCollect&&window.removeEventListener("scroll",scrollCollect),"object"==typeof preloader&&preloader.initLoading(),document.getElementById("rightside").style.cssText="opacity: ''; transform: ''",window.aplayers)for(let e=0;e<window.aplayers.length;e++)window.aplayers[e].options.fixed||window.aplayers[e].destroy();"object"==typeof typed&&typed.destroy();const e=document.body.classList;e.contains("read-mode")&&e.remove("read-mode"),"object"==typeof disqusjs&&disqusjs.destroy()})),document.addEventListener("pjax:complete",(function(){window.refreshFn(),document.querySelectorAll("script[data-pjax]").forEach((e=>{const t=document.createElement("script"),o=e.text||e.textContent||e.innerHTML||"";Array.from(e.attributes).forEach((e=>t.setAttribute(e.name,e.value))),t.appendChild(document.createTextNode(o)),e.parentNode.replaceChild(t,e)})),GLOBAL_CONFIG.islazyload&&window.lazyLoadInstance.update(),"function"==typeof chatBtnFn&&chatBtnFn(),"function"==typeof panguInit&&panguInit(),"function"==typeof gtag&&gtag("config","",{page_path:window.location.pathname}),"object"==typeof _hmt&&_hmt.push(["_trackPageview",window.location.pathname]),"function"==typeof loadMeting&&document.getElementsByClassName("aplayer").length&&loadMeting(),"object"==typeof Prism&&Prism.highlightAll(),"object"==typeof preloader&&preloader.endLoading()})),document.addEventListener("pjax:error",(e=>{404===e.request.status&&pjax.loadUrl("/404.html")}))</script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><script data-pjax>function butterfly_swiper_injector_config(){var s=document.getElementById("recent-posts");console.log("已挂载butterfly_swiper"),s.insertAdjacentHTML("afterbegin",'<div class="recent-post-item" style="height: auto;width: 100%"><div class="blog-slider swiper-container-fade swiper-container-horizontal" id="swiper_container"><div class="blog-slider__wrp swiper-wrapper" style="transition-duration: 0ms;"><div class="blog-slider__item swiper-slide" style="background:url(https://cdn1.tianli0.top/gh/web-xc/iMG/postss/vue.png);border-radius:12px;opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><div class="blog-slider__content"><span class="blog-slider__code">2023-08-31</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;post/ds2s/&quot;);" href="javascript:void(0);" alt="">整个前端面试题</a><div class="blog-slider__text">点击查看</div></div></div><div class="blog-slider__item swiper-slide" style="background:url(https://cdn1.tianli0.top/gh/web-xc/iMG/postss/vue.png);border-radius:12px;opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><div class="blog-slider__content"><span class="blog-slider__code">2023-08-28</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;post/ds23/&quot;);" href="javascript:void(0);" alt="">常见前端面试题</a><div class="blog-slider__text">点击查看</div></div></div><div class="blog-slider__item swiper-slide" style="background:url(https://cdn1.tianli0.top/gh/web-xc/iMG/postss/vue.png);border-radius:12px;opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><div class="blog-slider__content"><span class="blog-slider__code">2023-07-26</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;post/fe33/&quot;);" href="javascript:void(0);" alt="">硅谷甄选运营平台</a><div class="blog-slider__text">点击查看</div></div></div><div class="blog-slider__item swiper-slide" style="background:url(https://cdn1.tianli0.top/gh/web-xc/iMG/postss/vue.png);border-radius:12px;opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><div class="blog-slider__content"><span class="blog-slider__code">2023-07-17</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;post/ew32/&quot;);" href="javascript:void(0);" alt="">Vue第三天</a><div class="blog-slider__text">点击查看</div></div></div><div class="blog-slider__item swiper-slide" style="background:url(https://cdn1.tianli0.top/gh/web-xc/iMG/postss/vue.png);border-radius:12px;opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><div class="blog-slider__content"><span class="blog-slider__code">2023-07-16</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;post/aw92/&quot;);" href="javascript:void(0);" alt="">Vue第二天</a><div class="blog-slider__text">点击查看</div></div></div><div class="blog-slider__item swiper-slide" style="background:url(https://cdn1.tianli0.top/gh/web-xc/iMG/postss/vue.png);border-radius:12px;opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><div class="blog-slider__content"><span class="blog-slider__code">2023-07-14</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;post/ou67/&quot;);" href="javascript:void(0);" alt="">Vue第一天</a><div class="blog-slider__text">点击查看</div></div></div><div class="blog-slider__item swiper-slide" style="background:url(https://cdn1.tianli0.top/gh/web-xc/iMG/postss/vue.png);border-radius:12px;opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><div class="blog-slider__content"><span class="blog-slider__code">2023-07-05</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;post/fn32/&quot;);" href="javascript:void(0);" alt="">Vue框架笔记</a><div class="blog-slider__text">点击查看</div></div></div><div class="blog-slider__item swiper-slide" style="background:url(https://npm.elemecdn.com/webxc/cover/js1.webp);border-radius:12px;opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><div class="blog-slider__content"><span class="blog-slider__code">2023-06-21</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;post/fe11/&quot;);" href="javascript:void(0);" alt="">Vue前置JS功底</a><div class="blog-slider__text">点击查看</div></div></div><div class="blog-slider__item swiper-slide" style="background:url(https://cdn1.tianli0.top/gh/web-xc/iMG/postss/promise.webp);border-radius:12px;opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><div class="blog-slider__content"><span class="blog-slider__code">2023-06-11</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;post/pr67/&quot;);" href="javascript:void(0);" alt="">ES6-Promise语法与原理</a><div class="blog-slider__text">点击查看</div></div></div><div class="blog-slider__item swiper-slide" style="background:url(https://cdn1.tianli0.top/gh/web-xc/iMG/postss/ajax.webp);border-radius:12px;opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><div class="blog-slider__content"><span class="blog-slider__code">2023-06-08</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;post/or01/&quot;);" href="javascript:void(0);" alt="">Ajax第四天</a><div class="blog-slider__text">点击查看</div></div></div><div class="blog-slider__item swiper-slide" style="background:url(https://cdn1.tianli0.top/gh/web-xc/iMG/postss/ajax.webp);border-radius:12px;opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><div class="blog-slider__content"><span class="blog-slider__code">2023-06-07</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;post/fs67/&quot;);" href="javascript:void(0);" alt="">Ajax第三天</a><div class="blog-slider__text">点击查看</div></div></div><div class="blog-slider__item swiper-slide" style="background:url(https://npm.elemecdn.com/webxc/cover/js1.webp);border-radius:12px;opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><div class="blog-slider__content"><span class="blog-slider__code">2023-05-11</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;post/fe66/&quot;);" href="javascript:void(0);" alt="">JS进阶第四天</a><div class="blog-slider__text">点击查看</div></div></div><div class="blog-slider__item swiper-slide" style="background:url(https://npm.elemecdn.com/webxc/cover/js1.webp);border-radius:12px;opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><div class="blog-slider__content"><span class="blog-slider__code">2023-05-10</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;post/fe99/&quot;);" href="javascript:void(0);" alt="">JS进阶第三天</a><div class="blog-slider__text">点击查看</div></div></div><div class="blog-slider__item swiper-slide" style="background:url(https://npm.elemecdn.com/webxc/cover/js1.webp);border-radius:12px;opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><div class="blog-slider__content"><span class="blog-slider__code">2023-05-05</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;post/us87/&quot;);" href="javascript:void(0);" alt="">JS进阶第二天</a><div class="blog-slider__text">点击查看</div></div></div><div class="blog-slider__item swiper-slide" style="background:url(https://npm.elemecdn.com/webxc@1.0.12/cover/cover15.jpg);border-radius:12px;opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><div class="blog-slider__content"><span class="blog-slider__code">2022-10-31</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;post/2db5/&quot;);" href="javascript:void(0);" alt="">移动开发-Flex布局</a><div class="blog-slider__text">点击查看</div></div></div><div class="blog-slider__item swiper-slide" style="background:url(https://npm.elemecdn.com/webxc@1.0.12/cover/cover16.jpg);border-radius:12px;opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><div class="blog-slider__content"><span class="blog-slider__code">2022-11-14</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;post/1c7e/&quot;);" href="javascript:void(0);" alt="">移动开发-媒体查询</a><div class="blog-slider__text">点击查看</div></div></div><div class="blog-slider__item swiper-slide" style="background:url(https://npm.elemecdn.com/webxc@1.0.12/cover/cover17.jpg);border-radius:12px;opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><div class="blog-slider__content"><span class="blog-slider__code">2022-11-17</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;post/7fc/&quot;);" href="javascript:void(0);" alt="">移动开发-响应式</a><div class="blog-slider__text">点击查看</div></div></div></div><div class="blog-slider__pagination swiper-pagination-clickable swiper-pagination-bullets"></div><div class="swiper-button-prev"></div><div class="swiper-button-next"></div></div></div>')}for(var elist="null".split(","),cpage=location.pathname,epage="all",flag=0,i=0;i<elist.length;i++)cpage.includes(elist[i])&&flag++;("all"===epage&&0==flag||epage===cpage)&&butterfly_swiper_injector_config()</script><script defer src="https://npm.elemecdn.com/webxc@1.0.12/css/swiper/swiper.min.js"></script><script defer data-pjax src="https://npm.elemecdn.com/webxc@1.0.12/css/swiper/swiper_init.js"></script></body></html>